package com.ssy.lingxi.settle.accounts.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 业务请款单DO
 * @author Saske
 * @date 2021/12/14
 * @version 2.0.0
 */
@Entity
@Table(schema = "public",name = "sa_apply_amount",
        indexes = {@Index(name = "sa_apply_amount_apply_no_idx",columnList = "applyNo",unique = true),
                @Index(name = "sa_apply_amount_applyAbstract_idx",columnList = "applyAbstract"),
                @Index(name = "sa_apply_amount_expectPayTime_idx",columnList = "expectPayTime"),
                @Index(name = "sa_apply_amount_status_idx",columnList = "status"),
                @Index(name = "sa_apply_amount_createTime_idx",columnList = "createTime"),
                @Index(name = "sa_apply_amount_buyer_member_id_idx",columnList = "buyerMemberId"),
                @Index(name = "sa_apply_amount_buyer_role_id_idx",columnList = "buyerRoleId"),
                @Index(name = "sa_apply_amount_payer_idx",columnList = "payer"),
                @Index(name = "sa_apply_amount_apply_type_idx",columnList = "applyType"),
                @Index(name = "sa_apply_amount_payee_idx",columnList = "payee")
})
public class ApplyAmountDO implements Serializable {

    private static final long serialVersionUID = -159024681655248741L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "apply_amount_seq")
    @SequenceGenerator(sequenceName = "sa_apply_amount_seq", name = "apply_amount_seq", allocationSize = 1)
    private Long id;

    /**
     * 请款单号
     */
    @Column(name = "applyNo",columnDefinition = "varchar(16)")
    private String applyNo;

    /**
     * 请款单状态
     * 定义：ApplyAmountStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer status;

    /**
     * 请款单内部状态
     * 定义：ApplyAmountInnerStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer InnerStatus;

    /**
     * 是否提交审核过，用于判断是否可以删除
     */
    @Column
    private Boolean hasSubmit;

    /**
     * 请款类型,定义在 ApplyAmountTypeEnum 中
     */
    @Column(columnDefinition = "int")
    private Integer applyType;

    /**
     * 请款单摘要
     */
    @Column(columnDefinition = "varchar(60)")
    private String applyAbstract;

    /**
     * 收款方
     */
    @Column(name = "payee")
    private String payee;

    /**
     * 付款方
     */
    @Column(name = "payer")
    private String payer;

    /**
     * 账号名称
     */
    @Column(name = "accountName")
    private String accountName;

    /**
     * 银行账号
     */
    @Column(columnDefinition = "varchar(50)")
    private String bankAccount;

    /**
     * 开户行
     */
    @Column(columnDefinition = "varchar(50)")
    private String bankDeposit;

    /**
     * 请款金额
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal applyAmount;

    /**
     * 预计付款日期
     */
    @Column(name = "expectPayTime")
    private LocalDateTime expectPayTime;

    /**
     * 付款方式：定义在 PurchaseContractPayTypeEnum 中
     */
    @Column(columnDefinition = "int")
    private Integer payWay;

    /**
     * 付款方式参数-月：付款方式为账期-月，显示月数
     */
    @Column(columnDefinition = "int")
    private Integer payMonth;

    /**
     * 付款方式参数-日：付款方式为账期-月或者账期-天，显示日期或天数
     */
    @Column(columnDefinition = "int")
    private Integer payDate;

    /**
     * 支付方式,定义在MoneyPayWayEnum中
     */
    @Column(columnDefinition = "int")
    private Integer moneyPayWay;

    /**
     * 请款备注
     */
    @Column(name = "remark",columnDefinition = "varchar(80)")
    private String remark;

    /**
     * 对应对账单ID
     */
    @Column(name = "reconciliationId")
    private Long reconciliationId;

    /**
     * 对应对账单号
     */
    @Column(name = "reconciliationNo",columnDefinition = "varchar(50)")
    private String reconciliationNo;

    /**
     * 单据时间
     */
    @Column(name = "createTime")
    private LocalDateTime createTime;

    /**
     * 买方（采购）会员Id
     */
    @Column
    private Long buyerMemberId;

    /**
     * 买方（采购）会员角色Id
     */
    @Column
    private Long buyerRoleId;

    /**
     * 卖方（供应）会员Id
     */
    @Column
    private Long vendorMemberId;

    /**
     * 卖方（供应）会员角色Id
     */
    @Column
    private Long vendorRoleId;

    /**
     * 实际支付时间
     */
    @Column
    private LocalDateTime payTime;

    /**
     * 一对多双向关联请款单行明细
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "apply", cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, fetch = FetchType.LAZY)
    private List<ApplyAmountRowDO> rows;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getApplyNo() {
        return applyNo;
    }

    public void setApplyNo(String applyNo) {
        this.applyNo = applyNo;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getInnerStatus() {
        return InnerStatus;
    }

    public void setInnerStatus(Integer innerStatus) {
        InnerStatus = innerStatus;
    }

    public Boolean getHasSubmit() {
        return hasSubmit;
    }

    public void setHasSubmit(Boolean hasSubmit) {
        this.hasSubmit = hasSubmit;
    }

    public Integer getApplyType() {
        return applyType;
    }

    public void setApplyType(Integer applyType) {
        this.applyType = applyType;
    }

    public String getApplyAbstract() {
        return applyAbstract;
    }

    public void setApplyAbstract(String applyAbstract) {
        this.applyAbstract = applyAbstract;
    }

    public String getPayee() {
        return payee;
    }

    public void setPayee(String payee) {
        this.payee = payee;
    }

    public String getPayer() {
        return payer;
    }

    public void setPayer(String payer) {
        this.payer = payer;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    public String getBankDeposit() {
        return bankDeposit;
    }

    public void setBankDeposit(String bankDeposit) {
        this.bankDeposit = bankDeposit;
    }

    public BigDecimal getApplyAmount() {
        return applyAmount;
    }

    public void setApplyAmount(BigDecimal applyAmount) {
        this.applyAmount = applyAmount;
    }

    public LocalDateTime getExpectPayTime() {
        return expectPayTime;
    }

    public void setExpectPayTime(LocalDateTime expectPayTime) {
        this.expectPayTime = expectPayTime;
    }

    public Integer getPayWay() {
        return payWay;
    }

    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }

    public Integer getPayMonth() {
        return payMonth;
    }

    public void setPayMonth(Integer payMonth) {
        this.payMonth = payMonth;
    }

    public Integer getPayDate() {
        return payDate;
    }

    public void setPayDate(Integer payDate) {
        this.payDate = payDate;
    }

    public Integer getMoneyPayWay() {
        return moneyPayWay;
    }

    public void setMoneyPayWay(Integer moneyPayWay) {
        this.moneyPayWay = moneyPayWay;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getReconciliationId() {
        return reconciliationId;
    }

    public void setReconciliationId(Long reconciliationId) {
        this.reconciliationId = reconciliationId;
    }

    public String getReconciliationNo() {
        return reconciliationNo;
    }

    public void setReconciliationNo(String reconciliationNo) {
        this.reconciliationNo = reconciliationNo;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getBuyerMemberId() {
        return buyerMemberId;
    }

    public void setBuyerMemberId(Long buyerMemberId) {
        this.buyerMemberId = buyerMemberId;
    }

    public Long getBuyerRoleId() {
        return buyerRoleId;
    }

    public void setBuyerRoleId(Long buyerRoleId) {
        this.buyerRoleId = buyerRoleId;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public LocalDateTime getPayTime() {
        return payTime;
    }

    public void setPayTime(LocalDateTime payTime) {
        this.payTime = payTime;
    }

    public List<ApplyAmountRowDO> getRows() {
        return rows;
    }

    public void setRows(List<ApplyAmountRowDO> rows) {
        this.rows = rows;
    }
}
